﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using Numbers.Arithmatic;

namespace Numbers
{
    /// <summary>
    /// Represents an alpha that is the ration of background tagging efficiencies. In that sense, this is not
    /// something that you can set - just a number that is calculated.
    /// </summary>
    public class Alpha_12 : INotifyPropertyChanged
    {
        /// <summary>
        /// Always have to create this with others in mind! Sorry! :-)
        /// </summary>
        /// <param name="eNum"></param>
        /// <param name="eDenom"></param>
        public Alpha_12(epsilon_12 eNum, epsilon_12 eDenom)
        {
            ValueValue = new Value();
            ValueValue.PropertyChanged += new PropertyChangedEventHandler(ValueValue_PropertyChanged);

            Division.Create(new Operand(ValueValue),
                new Operand(eNum.ValueValue, true),
                new Operand(eDenom.ValueValue, true));

        }

        /// <summary>
        /// The result has changed - send the note around!
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void ValueValue_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            OnPropertyChanged("Value");
        }

        /// <summary>
        /// Send around the notification that a particular paroperty has changed.
        /// </summary>
        /// <param name="propName"></param>
        private void OnPropertyChanged(string propName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
            }
        }
        
        /// <summary>
        /// Returns the current value. Only getting is allowed!
        /// </summary>
        public double Value { get { return ValueValue.Val; } }

        /// <summary>
        /// Get the value we are setting here
        /// </summary>
        public Value ValueValue { get; private set; }

        /// <summary>
        /// The event we fire when things change!
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;
    }
}
